package TestPaperSystem.utils;

import com.google.gson.Gson;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

public class ResponseUtils_R implements Encoder.Text<R<Object>> {

    public static R<Object> success(Object value){
        return new R(200,"成功",value , true);
    }

    public static R<Object> error(Object value){
        return new R(404,"失败",value , false);
    }

    @Override
    public String encode(R<Object> objectR) throws EncodeException {
        return new Gson().toJson(objectR);
    }

    @Override
    public void init(EndpointConfig endpointConfig) {

    }

    @Override
    public void destroy() {

    }
}

